﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public void MapWASTAMM(ref DataRow dwLocal, DataRow dwData, bool flgExist = false, bool IsUseCurrentWS05 = false)
        {
            //WAPROGRP WAARTGRP
            #region
            dwLocal["WABEZ"] = dwData["WABEZ"];
            dwLocal["WAPROGRP"] = dwData["WAPROGRP"];
            dwLocal["WAARTGRP"] = dwData["WAARTGRP"];
            dwLocal["WAUEBM"] = dwData["WAUEBM"];
            dwLocal["WARWBRT"] = dwData["WARWBRT"];
            dwLocal["WAFBRTL"] = dwData["WAFBRTL"];
            dwLocal["WAFBRTU"] = dwData["WAFBRTU"];
            dwLocal["WAMANDANT"] = Left(dwData["WAMANDANT"].ToString() + "  ", 2);
            dwLocal["WAART"] = Left(dwData["WAART"].ToString() + "                                         ", 20);
            dwLocal["WAVAR"] = Left(dwData["WAVAR"].ToString() + "  ", 2);
            dwLocal["WAVWART"] = Left(dwData["WAART"].ToString() + "                                         ", 20);
            dwLocal["WAVWVAR"] = Left(dwData["WAVAR"].ToString() + "  ", 2);
            dwLocal["WAKAART"] = Left(dwData["WAART"].ToString() + "                                         ", 20);
            dwLocal["WAKAVAR"] = Left(dwData["WAVAR"].ToString() + "  ", 2);
            dwLocal["WARABLOM"] = dwData["WARABLOM"].ToString();
            dwLocal["WADART"] = Left(dwData["WADART"].ToString() + "                                         ", 20);
            dwLocal["WADVAR"] = Left(dwData["WADVAR"].ToString() + "  ", 2);
            dwLocal["WASUBSTGR"] = Left(dwData["WAART"].ToString() + "                                         ", 3);
            dwLocal["WARBEM"] = Left(dwData["WARBEM"].ToString().Trim() + "                                         ", 40);
            dwLocal["WAAENB"] = dwData["WAAENB"];
            dwLocal["WAAEND"] = dwData["WAAEND"];

            dwLocal["WAFSTDLG"] = dwData["WARSTDLG"];
            dwLocal["WARSTDLG"] = dwData["WARSTDLG"];
            dwLocal["WAGFKZ"] = dwData["WAGFKZ"];
            dwLocal["WAFFERTKZ"] = dwData["WAFFERTKZ"];
            dwLocal["WAFRBST"] = dwData["WAFRBST"];

            dwLocal["WAALKV"] = dwData["WAALKV"];
            dwLocal["WAFGWTOL"] = dwData["WAFGWTOL"];
            dwLocal["WARFDDIK"] = dwData["WARFDDIK"];
            dwLocal["WARFDDIS"] = dwData["WARFDDIS"];
            dwLocal["WAFFDDIK"] = dwData["WAFFDDIK"];
            dwLocal["WAFFDDIS"] = dwData["WAFFDDIS"];
            dwLocal["WAFDDIM"] = dwData["WAFDDIM"];
            dwLocal["WARGRLFD"] = dwData["WARGRLFD"];
            dwLocal["WAFGRLFD"] = dwData["WAFGRLFD"];
            dwLocal["WARGWTOL"] = dwData["WARGWTOL"];
            dwLocal["WATSDSCH"] = dwData["WATSDSCH"];
            dwLocal["WAFGRQM"] = dwData["WAFGRQM"];
            dwLocal["WARGRQM"] = dwData["WARGRQM"];
            dwLocal["WAFSTDGW"] = dwData["WAFSTDGW"];
            dwLocal["WARSTDGW"] = dwData["WARSTDGW"];
            dwLocal["WAARTGRP"] = dwData["WAARTGRP"];
            dwLocal["WAPROGRP"] = dwData["WAPROGRP"];
            dwLocal["WARSTDLG"] = dwData["WARSTDLG"];
            dwLocal["WAFSTDLG"] = dwData["WAFSTDLG"];
            dwLocal["WABIND"] = Left(dwData["WABIND"].ToString() + "               ", 15);
            dwLocal["WAEINZNR"] = Left(dwData["WAEINZNR"].ToString() + "                ", 15);
            dwLocal["WALAEAEND"] = dwData["WALAEAEND"];
            dwLocal["WAGASTA"] = "V";
            dwLocal["WARSTAKZ"] = "A";
            #endregion
            if (dwData["WARFERTKZ"].ToString() != "E")
            {
                dwLocal["WARFERTKZ"] = dwData["WARFERTKZ"];
                dwLocal["WAGASTA"] = dwData["WAGASTA"];
                dwLocal["WAMASTA"] = dwData["WAMASTA"];
                dwLocal["WAKESTA"] = dwData["WAKESTA"];
                dwLocal["WAMATPRF"] = dwData["WAMATPRF"];
                dwLocal["WABRTPRF"] = dwData["WABRTPRF"];
                dwLocal["WASTKGP"] = dwData["WASTKGP"];
                dwLocal["WASCHLIP"] = dwData["WASCHLIP"];
                dwLocal["WASCHLIA"] = dwData["WASCHLIA"];
                dwLocal["WALIEFNR"] = dwData["WALIEFNR"];
                dwLocal["WAEG"] = dwData["WAEG"];
            }
            if (IsUseCurrentWS05
                && flgExist)
            {
            }
            else
            {
                #region=====else==========
                dwLocal["WABEZ"] = Left(dwData["WABEZ"].ToString().Trim() + "                                         ", 40);
                dwLocal["WANEUB"] = dwData["WANEUB"].ToString();
                dwLocal["WANEUD"] = dwData["WANEUD"].ToString();
                #endregion
            }
        }
        public void SaveWASTAMM(DataRow dwData, DataRow dwDispo)
        {
            try
            {


                DataSet setResult = new DataSet();
                DataTable tbLocal = null;
                DataRow dwLocal = null;
                bool flgExist = false;
                bool IsUseCurrentWS05 = true;
                setResult = QueryWASTAMM(dwData);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    if (tbLocal.Rows.Count > 0)
                    {
                        flgExist = true;
                        dwLocal = tbLocal.Rows[0];
                    }
                    else
                    {
                        dwLocal = tbLocal.NewRow();
                    }
                }

                MapWASTAMM(ref dwLocal, dwData, flgExist, IsUseCurrentWS05);

                if (!flgExist)
                {
                    InsertWASTAMM(dwLocal);
                }
                UpdateWASTAMM(dwLocal);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void InsertWASTAMM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (Company)
            {
                case "JLT":
                    or1.CommandText = "INSERT INTO WASTAMM(WAMANDANT, WAKUNDNR, WAWERK, WAABT, WAART, WAVAR, WAAENZL, WAAENB, WAAEND, WANEUB, WANEUD, WABEZ, WAMTART, WAMU, WARKZ, WAFKZ, WAMUART, WAMUNR, WAHERLD, WAFDDIM, WAMURLOD, WAMUPROD, WAMUCTOD, WAMUDTRL, WAMUBIRL, WAGASTA, WAMASTA, WAKESTA, WAROSTA, WARBSTA, WAFBSTA, WARPROF, WAFPROF, WARLSTA, WAFLSTA, WARSTAKZ, WAWAART, WARFERTKZ, WARKL, WARMEHRB, WARVOLL, WARAUFM, WATRAUFM, WATRLG, WARSTDLG, WARSTDGW, WARABLOM, WARMUNR, WARBEM, WATEXTE1, WATEXTE2, WATEXTE3, WATEXTE4, WAKRITI, WARGKZ1, WAGFKZ, WARAUFT, WARAUFD, WARUNGLFM, WARUNGQM, WARUNBRT, WARUNFDK, WARUNFDS, WARWBRT, WARBRLST, WARBRTOL, WARGRQM, WARGRLFD, WARGWTOL, WARARTDICKE, WARARTTOLP, WARARTTOLM, WARFDDIK, WARFDDIS, WABIND, WARIPP, WASCHLICHTGR, WASCHLICHTNR, WAEINZNR, WATSDSCH, WASTTEIL, WAFSTAKZ, WAFFERTKZ, WAAUSART, WASTUEART, WAVWART, WAVWVAR, WAVARFR, WAFMEHRB, WAFVOLL, WAFAUFM, WAFSTDLG, WAFSTDGW, WAFABLOM, WAGVORL, WAOVORL, WAFRBST, WALAMFR, WAFGKZ1, WAFGKZ2, WAFGKZ3, WASCHLKZ, WAFAUFT, WAFAUFD, WAFKART, WAKOLL, WAFBEM, WAFUNGLFM, WAFUNGQM, WAFUNBRT, WAFUNFDK, WAFUNFDS, WAFBRTU, WAFBRTUT, WAFBRTL, WAFBRTLT, WASCHNK, WALAEAEND, WARENDEM, WARENDEMNT, WAGWVERL, WAALKV, WAFGRQM, WAFGRLFD, WAFGWTOL, WAFARTDICKE, WAFARTTOLP, WAFARTTOLM, WAFFDDIK, WAFFDDIS, WAUNI, WACOLORKZ, WAUNIGA, WAGEWICHT2, WAFVERF1, WAFVERF2, WAFVERF3, WAFVERF4, WAFZUSTAND1, WAFZUSTAND2, WAFZUSTAND3, WAFZUSTAND4, WAFVERFN1, WAFVERFN2, WAFVERFN3, WAFVERFN4, WAFFGRPN1, WAFFGRPN2, WAFFGRPN3, WAFFGRPN4, WAVNRKZ, WAZUSTKZ, WAUEKLOKZ, WAFSUBST, WAMAXFA, WAAKZWG, WAFRESTF, WADRUCKBAR, WAVBRGQM, WALEDR, WADVERF1, WADVERF2, WADVERF3, WADVERF4, WADZUSTAND1, WADZUSTAND2, WADZUSTAND3, WADZUSTAND4, WADVERFN1, WADVERFN2, WADVERFN3, WADVERFN4, WADFGRPN1, WADFGRPN2, WADFGRPN3, WADFGRPN4, WADSUBST, WADRESTF, WAFAKTOR, WABSUBST, WAVORBWA, WANACHBWA, WAVORBFB, WANACHBFB, WAVORBDR, WANACHBDR, WAVORBAP, WANACHBAP, WAMVB, WAMNB, WACVB, WACNB, WABVB, WABNB, WASVB, WASNB, WASUBSTGR, WAHANDICAP, WAZUSCHAB, WALOSGRFB, WAQCCHECK, WADART, WADVAR, WADSTDKZ, WADSACHB, WASCHNKZ, WAPROGRP, WAARTGRP, WAWBZEIT, WAMINBST, WAMAXBST, WAOPTMGR, WAOPTMGF, WARMINPMENG, WAFMINPMENG, WAUEBM, WAUEBG, WAUEBF, WAMATPRF, WABRTPRF, WAGQMPRF, WASTKGP, WASCHLIP, WASCHLIA, WALPABR, WADISPZS, WADRPAR, WAZUSTR, WAWDSUM, WASTSKZ, WASTSART, WASTSAUF, WASTSLG, WASTSDKZ, WAFILLER1, WAVOLU, WAVOLAM, WAVOLDIAM, WAVOLMTR, WAVOLAMVOL, WAANAB, WAALBIS, WAPLGRP, WAPRODH, WAMATKL, WAPMGRP, WAPRFSCHL, WAKAART, WAKAVAR, WAKASTD, WAKAZGRP, WAKAPRGRPN1, WAKAPRGRPN2, WAKAPRGRPN3, WAKAAGRA, WAKAAGRP, WAZWTWAHL, WAVERL, WAABR, WAABRTOL, WAKABRT, WARKABRTOL, WAFKABRTOL, WAMATKTO, WAKTO1, WAGV, WAKBON, WAMGKMM, WAMEZ, WAWAG, WABKLAS, WABWPLAN, WAEKGRP, WABSTME, WAVABME, WAEKWSL, WALIEFNR, WAEG, WABON, WAKUNDE, WALOHNW, WALOHNA, WASCHLIAUF, WAPFCODE, WAAUFKZ, WAMRKM1, WAMRKM2, WAMRKM3, WAMRKM4, WAMRKM5, WAESACHB, WAESACHBKZ, WAFBGRLFM, WAPRUEFKZ, WAPRUEFBEN, WAPRUEFDAT, WARAVGRP, WATAX, WAPARTBA, WAFDDIF, WAINSPCOR, WAINSPGRP, WAKENNFD, WAFILLER2)"
                        + " VALUES (:WAMANDANT, '00000000', '   ', '   ',:WAART, '  ', 1, :WAVAR, 20140107, :WANEUB, :WANEUD, '01                                      ', '    ', ' ', 'J', 'J', '                    ', '                    ', '   ', 'INC', '00', '00', ' ', 0, '        ', 'V', 'V', 'V', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'A', 'GEW', 'E', '    ', ' ', 'P', '  ', '  ', 0, 130000, 20410, 'F99999    ', '               ', '                                        ', '          ', '          ', '          ', '          ', 'N', ' ', 'J', '        ', 0, ' ', ' ', ' ', ' ', ' ', 1570, 0, 0, 100, 157, 200, '0000', '0000', '0000', 11800, 7700, 'J3-2014        ', 0, '     ', '000000000000000', 'J3-2014        ', 3941, 'J', 'A', 'E', 'FI  ', '   ',:WAART, '  ', 'J', ' ', 'P', '  ', 200000, 3140, '          ', '          ', '          ', 'C ', 'N', ' ', ' ', ' ', ' ', '        ', 0, '          ', '     ', '                                        ', ' ', ' ', ' ', ' ', ' ', 1460, 0, 1460, 0, 0, 5, 0, 0, 0, '00', 108, 157, 0, '0000', '0000', '0000', 12700, 7800, ' ', ' ', ' ', 0, '   ', '   ', '   ', '   ', '    ', '    ', '    ', '    ', '   ', '   ', '   ', '   ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '               ', 0, 0, 0, ' ', 0, 0, '   ', '   ', '   ', '   ', '    ', '    ', '    ', '    ', '   ', '   ', '   ', '   ', ' ', ' ', ' ', ' ', '               ', 0, 0, '               ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', 'J3-', '   ', 0, 0, ' ', :WAART, '  ', 'J', '        ', ' ', 'MS ', '12 ', '00', 0, 0, 5000, 5000, 0, 0, 'M  ', '2', '000001000000', ' ', ' ', ' ', ' ', ' ', ' ', 'N', 'N', '     ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '          ', 0, '  ', 0, 0, 0, 0, 0, '  ', '                  ', '         ', '    ', '         ', :WAART, '  ', 'J', 'GGG', ' ', ' ', ' ', '     ', '  ', 80, 50, 0, '0', 0, 0, 0, '      ', '      ', '      ', 0, '        ', 0, 0, '    ', ' ', '   ', '   ', ' ', '    ', '        ', 'N', 'N', '        ', '                    ', '                    ', 0, '     ', ' ', '    ', '    ', '    ', '    ', '    ', '        ', 'B', 0, 'N', '        ', 0, '10  ', 'RMB', ' ', 25400, '    ', '    ', ' ', '                               ')";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                    or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
                    or1.Parameters.Add("WANEUB", OracleType.NVarChar).Value = dwData["WANEUB"].ToString();
                    or1.Parameters.Add("WANEUD", OracleType.Number).Value = dwData["WANEUD"].ToString();
                    break;
                default:
                    or1.CommandText = "INSERT INTO WASTAMM(WAMANDANT, WAKUNDNR, WAWERK, WAABT, WAART, WAVAR, WAAENZL, WAAENB, WAAEND, WANEUB, WANEUD, WABEZ, WAMTART, WAMU, WARKZ, WAFKZ, WAMUART, WAMUNR, WAHERLD, WAFDDIM, WAMURLOD, WAMUPROD, WAMUCTOD, WAMUDTRL, WAMUBIRL, WAGASTA, WAMASTA, WAKESTA, WAROSTA, WARBSTA, WAFBSTA, WARPROF, WAFPROF, WARLSTA, WAFLSTA, WARSTAKZ, WAWAART, WARFERTKZ, WARKL, WARMEHRB, WARVOLL, WARAUFM, WATRAUFM, WATRLG, WARSTDLG, WARSTDGW, WARABLOM, WARMUNR, WARBEM, WATEXTE1, WATEXTE2, WATEXTE3, WATEXTE4, WAKRITI, WARGKZ1, WAGFKZ, WARAUFT, WARAUFD, WARUNGLFM, WARUNGQM, WARUNBRT, WARUNFDK, WARUNFDS, WARWBRT, WARBRLST, WARBRTOL, WARGRQM, WARGRLFD, WARGWTOL, WARARTDICKE, WARARTTOLP, WARARTTOLM, WARFDDIK, WARFDDIS, WABIND, WARIPP, WASCHLICHTGR, WASCHLICHTNR, WAEINZNR, WATSDSCH, WASTTEIL, WAFSTAKZ, WAFFERTKZ, WAAUSART, WASTUEART, WAVWART, WAVWVAR, WAVARFR, WAFMEHRB, WAFVOLL, WAFAUFM, WAFSTDLG, WAFSTDGW, WAFABLOM, WAGVORL, WAOVORL, WAFRBST, WALAMFR, WAFGKZ1, WAFGKZ2, WAFGKZ3, WASCHLKZ, WAFAUFT, WAFAUFD, WAFKART, WAKOLL, WAFBEM, WAFUNGLFM, WAFUNGQM, WAFUNBRT, WAFUNFDK, WAFUNFDS, WAFBRTU, WAFBRTUT, WAFBRTL, WAFBRTLT, WASCHNK, WALAEAEND, WARENDEM, WARENDEMNT, WAGWVERL, WAALKV, WAFGRQM, WAFGRLFD, WAFGWTOL, WAFARTDICKE, WAFARTTOLP, WAFARTTOLM, WAFFDDIK, WAFFDDIS, WAUNI, WACOLORKZ, WAUNIGA, WAGEWICHT2, WAFVERF1, WAFVERF2, WAFVERF3, WAFVERF4, WAFZUSTAND1, WAFZUSTAND2, WAFZUSTAND3, WAFZUSTAND4, WAFVERFN1, WAFVERFN2, WAFVERFN3, WAFVERFN4, WAFFGRPN1, WAFFGRPN2, WAFFGRPN3, WAFFGRPN4, WAVNRKZ, WAZUSTKZ, WAUEKLOKZ, WAFSUBST, WAMAXFA, WAAKZWG, WAFRESTF, WADRUCKBAR, WAVBRGQM, WALEDR, WADVERF1, WADVERF2, WADVERF3, WADVERF4, WADZUSTAND1, WADZUSTAND2, WADZUSTAND3, WADZUSTAND4, WADVERFN1, WADVERFN2, WADVERFN3, WADVERFN4, WADFGRPN1, WADFGRPN2, WADFGRPN3, WADFGRPN4, WADSUBST, WADRESTF, WAFAKTOR, WABSUBST, WAVORBWA, WANACHBWA, WAVORBFB, WANACHBFB, WAVORBDR, WANACHBDR, WAVORBAP, WANACHBAP, WAMVB, WAMNB, WACVB, WACNB, WABVB, WABNB, WASVB, WASNB, WASUBSTGR, WAHANDICAP, WAZUSCHAB, WALOSGRFB, WAQCCHECK, WADART, WADVAR, WADSTDKZ, WADSACHB, WASCHNKZ, WAPROGRP, WAARTGRP, WAWBZEIT, WAMINBST, WAMAXBST, WAOPTMGR, WAOPTMGF, WARMINPMENG, WAFMINPMENG, WAUEBM, WAUEBG, WAUEBF, WAMATPRF, WABRTPRF, WAGQMPRF, WASTKGP, WASCHLIP, WASCHLIA, WALPABR, WADISPZS, WADRPAR, WAZUSTR, WAWDSUM, WASTSKZ, WASTSART, WASTSAUF, WASTSLG, WASTSBRT, WASTSDKZ, WAFILLER1, WAVOLU, WAANAB, WAALBIS, WAPLGRP, WAPRODH, WAMATKL, WAPMGRP, WAPRFSCHL, WAKAART, WAKAVAR, WAKASTD, WAKAZGRP, WAKAPRGRPN1, WAKAPRGRPN2, WAKAPRGRPN3, WAKAAGRA, WAKAAGRP, WAZWTWAHL, WAVERL, WAABR, WAABRTOL, WAKABRT, WARKABRTOL, WAFKABRTOL, WAMATKTO, WAKTO1, WAGV, WAKBON, WAMGKMM, WAMEZ, WAWAG, WABKLAS, WABWPLAN, WAEKGRP, WABSTME, WAVABME, WAEKWSL, WALIEFNR, WAEG, WABON, WAKUNDE, WALOHNW, WALOHNA, WASCHLIAUF, WAPFCODE, WAAUFKZ, WAMRKM1, WAMRKM2, WAMRKM3, WAMRKM4, WAMRKM5, WAESACHB, WAESACHBKZ, WAFBGRLFM, WAPRUEFKZ, WAPRUEFBEN, WAPRUEFDAT, WARAVGRP, WATAX, WAPARTBA, WAFDDIF, WAFILLER2)"
                        + "VALUES (:WAMANDANT, '00000000', '   ', '   ', :WAART, :WAVAR, 1, '        ', 0, :WANEUB, :WANEUD, '                                        ', '    ', ' ', 'J', 'J', '                    ', '                    ', '   ', 'INC', '00', '00', ' ', 0, '        ', 'V', 'V', 'V', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'A', 'GEW', 'E', '    ', ' ', 'P', '  ', '  ', 0, 200000, 25400, '          ', '               ', '                                        ', '          ', '          ', '          ', '          ', 'N', ' ', 'J', '        ', 0, ' ', ' ', ' ', ' ', ' ', 0, 0, 0, 0, 0, 0, '0000', '0000', '0000', 0, 0, '               ', 0, '     ', '000000000000000', '               ', 0, 'J', 'A', 'E', 'FI  ', '   ', '                    ', '  ', 'J', ' ', 'P', '  ', 0, 0, '          ', '          ', '          ', 'C ', 'N', ' ', ' ', ' ', ' ', '        ', 0, '          ', '     ', '                                        ', ' ', ' ', ' ', ' ', ' ', 0, 0, 0, 0, 0,0, 0, 0, 0, '00', 0, 0, 0, '0000', '0000', '0000', 0, 0, ' ', ' ', ' ', 0, '   ', '   ', '   ', '   ', '    ', '    ', '    ', '    ', '   ', '   ', '   ', '   ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '               ', 0, 0, 0, ' ', 0, 0, '   ', '   ', '   ', '   ', '    ', '    ', '    ', '    ', '   ', '   ', '   ', '   ', ' ', ' ', ' ', ' ', '               ', 0, 0, '               ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', 0, 0, ' ', '                    ', '  ', 'J', '        ', ' ', '   ', '   ', '00', 0, 0, 5000, 5000, 0, 0, 'MTR', '2', '000001000000', ' ', ' ', ' ', ' ', ' ', ' ', 'N', 'N', '     ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '         ', 0, 0, 0, '  ', '                  ', '         ', '    ', '         ', '                    ', '  ', 'J', 'GGG', ' ', ' ', ' ', '     ', '  ', 80, 50, 0, '0', 0, 0, 0, '      ', '      ', '      ', 0, '        ', 0, 0, '    ', ' ', '   ', '   ', ' ', '    ', '        ', 'N', 'N', '        ', '                    ', '                    ', 0, '     ', ' ', '    ', '    ', '    ', '    ', '    ', '        ', 'B', 0, 'N', '        ', 0, '10  ', 'RMB', ' ', 25400, '                                                      ')";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                    or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
                    or1.Parameters.Add("WANEUB", OracleType.NVarChar).Value = dwData["WANEUB"].ToString();
                    or1.Parameters.Add("WANEUD", OracleType.Number).Value = dwData["WANEUD"].ToString();
                    break;
            }
            Connect2Proxy(or1);
        }
        public void DeleteWASTAMM(string client, string art, string var)
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE WASTAMM WHERE  "
            + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
            or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("WAART", OracleType.NVarChar).Value = art;
            or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = var;
            Connect2Proxy(or1);
        }
        public DataSet QueryWASTAMM(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM WASTAMM WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                    + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                    or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                        + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                    or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
                    break;

                case 3:
                    or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                    + "  WAMANDANT=:WAMANDANT AND WAART=:WAART";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                    break;
                case 31:
                    or1.CommandText = "SELECT WAART AS FSART FROM WASTAMM WHERE  "
                        + "  WAMANDANT=:WAMANDANT AND WAART=:WAART";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT WF.* FROM WDECK WD RIGHT JOIN WASTAMM WF ON"
                        + " WAMANDANT=WDMANDANT AND WAART=WDART AND WAVAR=WDVAR "
                        + " WHERE WAKUNDNR='        ' AND WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT WD.WDAUFKRS,WDAUFLFD,WDAUFPOS,WDSA,WDUPOS,W.* FROM WDECK  WD "
                        + " JOIN WASTAMM W ON WDART=W.WAART AND WDVAR=W.WAVAR "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT WAART,WABEZ,WAFBRTU,WAFBRTL,WAFGRQM,WAFGRLFD FROM WASTAMM WHERE  "
                        + "  WAMANDANT=:WAMANDANT AND (WAFBRTU=0 OR WAFBRTL=0 OR  WAFGRQM=0 OR WAFGRLFD=0 )";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    break;
                case 7:
                    or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                    + "  WAMANDANT=:WAMANDANT AND WAART LIKE '" + dwData["WAART"].ToString() + "%'";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                    break;
                case 8:
                    or1.CommandText = "SELECT DISTINCT M.* FROM WASTAMM M JOIN ABPOS ON ABPMANDANT=WAMANDANT AND ABPART=WAART   "
                       + " WHERE "
                    + " ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WASTAMM";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public void UpdateWASTAMM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE WASTAMM SET WABEZ=:WABEZ,WARBEM=:WARBEM"
                + ",WAAENB=:WAAENB,WAAEND=:WAAEND,WARABLOM=:WARABLOM,WAFGWTOL=:WAFGWTOL,WAALKV=:WAALKV"
                 + ",WAVWART=:WAVWART,WAVWVAR=:WAVWVAR,WAKAART=:WAKAART,WAKAVAR=:WAKAVAR,WADART=:WADART,WADVAR=:WADVAR"
                 + ",WASUBSTGR=:WASUBSTGR,WAPROGRP=:WAPROGRP,WAARTGRP=:WAARTGRP,WAFDDIM=:WAFDDIM"
                 + ",WAFFERTKZ=:WAFFERTKZ,WARFERTKZ=:WARFERTKZ,WAGFKZ=:WAGFKZ,WAFRBST=:WAFRBST"
                 + ",WAMASTA=:WAMASTA,WAKESTA=:WAKESTA,WAMATPRF=:WAMATPRF,WABRTPRF=:WABRTPRF,WASTKGP=:WASTKGP,WASCHLIP=:WASCHLIP,WASCHLIA=:WASCHLIA,WALIEFNR=:WALIEFNR,WAEG=:WAEG"
                 + ",WARSTDLG=:WARSTDLG,WARSTDGW=:WARSTDGW,WAFSTDLG=:WAFSTDLG,WAFSTDGW=:WAFSTDGW "
                 + ",WARSTAKZ=:WARSTAKZ,WAGASTA=:WAGASTA,WAUEBM=:WAUEBM"
                 + ",WARWBRT= :WARWBRT,WAFBRTL=:WAFBRTL,WAFBRTU=:WAFBRTU,WARGRQM=:WARGRQM, WAFGRQM=:WAFGRQM, WARGRLFD=:WARGRLFD, WAFGRLFD=:WAFGRLFD, WARGWTOL=:WARGWTOL"
                 + ",WARFDDIK=:WARFDDIK, WARFDDIS=:WARFDDIS, WAFFDDIK=:WAFFDDIK,WAFFDDIS=:WAFFDDIS,WABIND=:WABIND, WAEINZNR=:WAEINZNR, WATSDSCH=:WATSDSCH, WALAEAEND=:WALAEAEND"
                + " WHERE  "
         + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";

            or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
            or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
            or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
            or1.Parameters.Add("WABEZ", OracleType.NVarChar).Value = dwData["WABEZ"].ToString();
            or1.Parameters.Add("WARBEM", OracleType.NVarChar).Value = dwData["WARBEM"].ToString();
            or1.Parameters.Add("WAAENB", OracleType.NVarChar).Value = dwData["WAAENB"].ToString();
            or1.Parameters.Add("WAAEND", OracleType.DateTime).Value = dwData["WAAEND"].ToString();
            or1.Parameters.Add("WARABLOM", OracleType.DateTime).Value = dwData["WARABLOM"].ToString();
            or1.Parameters.Add("WARSTAKZ", OracleType.DateTime).Value = dwData["WARSTAKZ"].ToString();
            or1.Parameters.Add("WAGASTA", OracleType.DateTime).Value = dwData["WAGASTA"].ToString();
            or1.Parameters.Add("WAUEBM", OracleType.DateTime).Value = dwData["WAUEBM"].ToString();

            or1.Parameters.Add("WAVWART", OracleType.NVarChar).Value = dwData["WAVWART"].ToString();
            or1.Parameters.Add("WAVWVAR", OracleType.NVarChar).Value = dwData["WAVWVAR"].ToString();
            or1.Parameters.Add("WAKAART", OracleType.NVarChar).Value = dwData["WAKAART"].ToString();
            or1.Parameters.Add("WAKAVAR", OracleType.NVarChar).Value = dwData["WAKAVAR"].ToString();
            or1.Parameters.Add("WADART", OracleType.NVarChar).Value = dwData["WADART"].ToString();
            or1.Parameters.Add("WADVAR", OracleType.NVarChar).Value = dwData["WADVAR"].ToString();

            or1.Parameters.Add("WASUBSTGR", OracleType.NVarChar).Value = dwData["WASUBSTGR"].ToString();
            or1.Parameters.Add("WAPROGRP", OracleType.NVarChar).Value = dwData["WAPROGRP"].ToString();
            or1.Parameters.Add("WAARTGRP", OracleType.NVarChar).Value = dwData["WAARTGRP"].ToString();
            or1.Parameters.Add("WAFFERTKZ", OracleType.NVarChar).Value = dwData["WAFFERTKZ"].ToString();
            or1.Parameters.Add("WARFERTKZ", OracleType.NVarChar).Value = dwData["WARFERTKZ"].ToString();
            or1.Parameters.Add("WAGFKZ", OracleType.NVarChar).Value = dwData["WAGFKZ"].ToString();
            or1.Parameters.Add("WAFRBST", OracleType.NVarChar).Value = dwData["WAFRBST"].ToString();

            or1.Parameters.Add("WAMASTA", OracleType.NVarChar).Value = dwData["WAMASTA"].ToString();
            or1.Parameters.Add("WAKESTA", OracleType.NVarChar).Value = dwData["WAKESTA"].ToString();
            or1.Parameters.Add("WAMATPRF", OracleType.NVarChar).Value = dwData["WAMATPRF"].ToString();
            or1.Parameters.Add("WABRTPRF", OracleType.NVarChar).Value = dwData["WABRTPRF"].ToString();
            or1.Parameters.Add("WASTKGP", OracleType.NVarChar).Value = dwData["WASTKGP"].ToString();
            or1.Parameters.Add("WASCHLIP", OracleType.NVarChar).Value = dwData["WASCHLIP"].ToString();
            or1.Parameters.Add("WASCHLIA", OracleType.NVarChar).Value = dwData["WASCHLIA"].ToString();
            or1.Parameters.Add("WALIEFNR", OracleType.NVarChar).Value = dwData["WALIEFNR"].ToString();
            or1.Parameters.Add("WAEG", OracleType.NVarChar).Value = dwData["WAEG"].ToString();

            or1.Parameters.Add("WAFDDIM", OracleType.NVarChar).Value = dwData["WAFDDIM"].ToString();

            or1.Parameters.Add("WARSTDLG", OracleType.Number).Value = dwData["WARSTDLG"].ToString();
            or1.Parameters.Add("WARSTDGW", OracleType.Number).Value = dwData["WARSTDGW"].ToString();
            or1.Parameters.Add("WAFSTDLG", OracleType.Number).Value = dwData["WAFSTDLG"].ToString();
            or1.Parameters.Add("WAFSTDGW", OracleType.Number).Value = dwData["WAFSTDGW"].ToString();
            or1.Parameters.Add("WAALKV", OracleType.Number).Value = dwData["WAALKV"].ToString();

            or1.Parameters.Add("WARWBRT", OracleType.Number).Value = dwData["WARWBRT"].ToString();
            or1.Parameters.Add("WAFBRTL", OracleType.Number).Value = dwData["WAFBRTL"].ToString();
            or1.Parameters.Add("WAFBRTU", OracleType.DateTime).Value = dwData["WAFBRTU"].ToString();
            or1.Parameters.Add("WARGRQM", OracleType.Number).Value = dwData["WARGRQM"].ToString();
            or1.Parameters.Add("WAFGRQM", OracleType.Number).Value = dwData["WAFGRQM"].ToString();
            or1.Parameters.Add("WARGRLFD", OracleType.Number).Value = dwData["WARGRLFD"].ToString();
            or1.Parameters.Add("WAFGRLFD", OracleType.Number).Value = dwData["WAFGRLFD"].ToString();
            or1.Parameters.Add("WARGWTOL", OracleType.Number).Value = dwData["WARGWTOL"].ToString();
            or1.Parameters.Add("WAFGWTOL", OracleType.Number).Value = dwData["WAFGWTOL"].ToString();

            or1.Parameters.Add("WARFDDIK", OracleType.Number).Value = dwData["WARFDDIK"].ToString();
            or1.Parameters.Add("WARFDDIS", OracleType.Number).Value = dwData["WARFDDIS"].ToString();
            or1.Parameters.Add("WAFFDDIK", OracleType.Number).Value = dwData["WAFFDDIK"].ToString();
            or1.Parameters.Add("WAFFDDIS", OracleType.Number).Value = dwData["WAFFDDIS"].ToString();
            or1.Parameters.Add("WABIND", OracleType.NVarChar).Value = dwData["WABIND"].ToString();
            or1.Parameters.Add("WAEINZNR", OracleType.NVarChar).Value = dwData["WAEINZNR"].ToString();
            or1.Parameters.Add("WATSDSCH", OracleType.NVarChar).Value = dwData["WATSDSCH"].ToString();
            or1.Parameters.Add("WALAEAEND", OracleType.NVarChar).Value = dwData["WALAEAEND"].ToString();
            Connect2Proxy(or1);
        }
    }
}
